package com.yyj.dao;

import com.yyj.entity.Employee;
import com.yyj.entity.Params;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface EmployeeDao {
@Select("select * from employee")
List<Employee> getEmployee();

    List<Employee> getBySearch(@Param("params") Params params);

    @Insert("insert into employee (name,img,password,sex,age,phone,degree,experience,postId,office,grade) values (#{name },#{img},'123456',#{sex},#{age},#{phone},#{degree},#{experience},#{postId},#{office},#{grade})")
    void insertEmployee(Employee employee);

    @Update("update employee set name=#{name},img=#{img},password=#{password},sex=#{sex},age=#{age},phone=#{phone},degree=#{degree},experience=#{experience},postId=#{postId},office=#{office},grade=#{grade} where id=#{id}")
    void updateEmployee(Employee employee);

    @Delete("DELETE FROM employee WHERE id = #{id}")
    void deleteByPrimaryKey(Integer id);
    @Select("select * from user where name=#{name} limit 1")
    Employee findByName(@Param("name") String name);

    List<Employee> getEmployeesByPostIdOne(@Param("params") Params params);

    @Insert("insert into user (name,password,sex,age,phone) values (#{name },'123456',#{sex},#{age},#{phone})")
    void insert(Employee user);

    @Select("select employee.*,dept.role from employee left join dept ON employee.postId=dept.id where employee.name=#{name} and password=#{password}")
    Employee login(Employee employee);
    @Select("select * from employee where id=#{id}")
    Employee getInfo(Integer id);
}
